package streamandFile;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;


public class InputStreamReaderTest {

	public static void main(String[] args) throws Exception{
		BufferedReader br = null;
		try {//004
			FileInputStream fis = new FileInputStream("d:/EncodeTest.txt");
			InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
			br = new BufferedReader(isr);
			String line = null;
			while((line=br.readLine())!=null)
				System.out.println(line);
		} finally{
			if (br!=null){
				br.close();
			}
		}
	}
	public static void convertGBK2UTF8(String src, String dst) throws IOException{
		BufferedReader br = null;
		OutputStreamWriter osw = null;
		try {//004
			osw = new OutputStreamWriter(new FileOutputStream(dst),"UTF-8");
			
			String line = null;
			while((line=br.readLine())!=null)
				System.out.println(line);
		}catch(IOException e){
			e.printStackTrace();
		} 
		finally{
			br.close();
			osw.close();
		}
	}
}
